"""
@author: lyf
@file: 回合制游戏.py
@time: 2022/12/2 17:17
"""
import time
import random
class Role:
    def __init__(self, name, sex, equipment,blood=100):
        self.name = name
        self.sex = sex
        self.blood = blood
        self.equipment = equipment

    def attack(self, role):
        print("普通攻击")
        role.blood -= 10

    def defense(self, role):
        if role.equipment == 1 and role.blood <= 10000000:
            role.blood += 5

class u(Role):
    def skill_1(self,role):
        print("waaaaah！")
        role.blood -= 20

    def skill_2(self, role):
        print("赐予我力量！")
        self.blood += 30

    def skill_3(self, role):
        print("联盟万岁！")
        self.blood += 20

    def skill_4(self,role):
        print("为了震旦！")
        role.blood -= 20

    def eq_1(self,role):
        name = "认真的一拳"
        if role.blood <=1000:
            role.blood -= 5

    def eq_2(self,role):
        name = "冲冲冲的力量"
        if self.blood <=100:
            self.blood -= 5
            role.blood -= 15

class boss(Role):
    def skill_1(self, role):
        print("死吧，虫子！")
        role.blood -= 10

    def skill_2(self, role):
        print("桀桀桀桀！")
        self.blood += 30
        if self.blood > 100:
            self.blood = 100

    def skill_3(self, role):
        print("阿尼亚萨比戏~")
        self.blood -= 10

    def skill_4(self, role):
        print("此刻，既是永恒！")
        role.blood -= 20

class Room():
    def __init__(self, num):
        self.room = num
    def begin(self,roles):
        if len(roles) > 2:
            return False

name = input("请输入用户名")
sex = input("请输入性别")
a = u(name, sex, 1)
b = boss("假·"+name, sex, 0)

i = 1
while 1:
    print(f"第<{i}>回合")
    i = i + 1
    num1 = random.randint(0, 5)
    print(f"{a.name}释放技能——————》", end="")
    b.defense(b)
    if num1 == 0:
        a.attack(b)
        e = random.randint(0, 3)
        if e == 0:
            a.eq_1(b)
            print("您使用了认真的一拳")
        elif e == 1:
            a.eq_2(b)
            print("您使用了冲冲冲的力量")
        else:print("道具使用失败")
    elif num1 == 1:
        a.skill_1(b)
    elif num1 == 2:
        a.skill_2(b)
    elif num1 == 3:
        a.skill_3(b)
    elif num1 == 4:
        a.skill_4(b)
    elif num1 == 5:
        print("对方闪避了您的攻击")

    if a.blood <= 0 or b.blood <= 0:
         if a.blood > 0 :
             winner = a.name
         else:
             winner = b.name
         print(f"{winner}---Win")
         break

    num2 = random.randint(0, 4)
    print(f"{b.name}释放技能——————》", end="")
    a.defense(a)
    if num2 ==0:
        b.attack(a)
    elif num2 == 1:
        b.skill_1(a)
    elif num2 == 2:
        b.skill_2(a)
    elif num2 == 3:
        b.skill_3(a)
    elif num2 == 4:
        b.skill_4(a)

    if a.blood <= 0 or b.blood <= 0:
        if a.blood > 0:
            winner = a.name
        else:
            winner = b.name
        print(f"{winner}---Win")
        break
    print(f"{a.name}:hp--{a.blood}    vs   {b.name}:hp--{b.blood}")
    time.sleep(0.5)

